package cn.mujiankeji.mbrowser.界面.标签页

import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import cn.mujiankeji.mbrowser.BuildConfig
import cn.mujiankeji.mbrowser.app.应用接口
import cn.mujiankeji.mbrowser.界面.框架.主视图.标签页状态
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

class 关于页面状态() : 标签页状态() {
    var 应用版本 by mutableStateOf("")
    var coroutine: CoroutineScope? = null

    
    fun 加载版本信息() {
        应用版本 = "版本 ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
    }
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun 关于页面实现(state: 关于页面状态) {
    val scope = rememberCoroutineScope()
    
    LaunchedEffect(Unit) {
        state.coroutine = scope
        state.加载版本信息()
    }
    
    Scaffold(
        topBar = {
            TopAppBar(
                title = { Text("关于") },
            )
        }
    ) { paddingValues ->
        Column(
            modifier = Modifier
                .fillMaxSize()
                .padding(paddingValues)
                .padding(16.dp),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.spacedBy(16.dp)
        ) {
            Spacer(modifier = Modifier.height(16.dp))
            
            Text(
                text = "MBrowser",
                style = MaterialTheme.typography.headlineLarge
            )
            
            Text(
                text = state.应用版本,
                style = MaterialTheme.typography.bodyMedium
            )
            
            Spacer(modifier = Modifier.height(16.dp))
            
            Card(
                modifier = Modifier.fillMaxWidth()
            ) {
                Column(
                    modifier = Modifier
                        .fillMaxWidth()
                        .padding(16.dp),
                    verticalArrangement = Arrangement.spacedBy(8.dp)
                ) {
                    Text(
                        text = "应用简介",
                        style = MaterialTheme.typography.titleMedium
                    )
                    
                    Text(
                        text = "MBrowser 是一款基于 Kotlin 和 Jetpack Compose 开发的现代化安卓浏览器应用，致力于提供稳定、高效且功能丰富的移动浏览体验。",
                        style = MaterialTheme.typography.bodyMedium
                    )
                }
            }
            
            Card(
                modifier = Modifier.fillMaxWidth()
            ) {
                Column(
                    modifier = Modifier
                        .fillMaxWidth()
                        .padding(16.dp),
                    verticalArrangement = Arrangement.spacedBy(8.dp)
                ) {
                    Text(
                        text = "技术栈",
                        style = MaterialTheme.typography.titleMedium
                    )
                    
                    Text(
                        text = "• Kotlin\n• Jetpack Compose\n• MVVM 架构\n• Koin 依赖注入\n• Kotlin Coroutines & Flow\n• Room 数据库",
                        style = MaterialTheme.typography.bodyMedium
                    )
                }
            }
            
            Spacer(modifier = Modifier.weight(1f))
            
            Text(
                text = "© 2023-2024 木简科技",
                style = MaterialTheme.typography.bodySmall,
                textAlign = TextAlign.Center
            )
        }
    }
}

